package com.universal.schedule.timetable;

import android.content.res.ColorStateList;
import android.graphics.Color;

/**
 * Created by weihuajian on 16/6/12.
 */
public class ColorUtils {

    public static int getCourseBgColor(int colorFlag) {
        switch (colorFlag) {
            case 0:
                return Color.parseColor("#95e987");
            case 1:
                return Color.parseColor("#ffb67e");
            case 2:
                return Color.parseColor("#8cc7fe");
            case 3:
                return Color.parseColor("#7ba3eb");
            case 4:
                return Color.parseColor("#e3ade8");
            case 5:
                return Color.parseColor("#f9728b");
            case 6:
                return Color.parseColor("#85e9cd");
            case 7:
                return Color.parseColor("#f5a8cf");
            case 8:
                return Color.parseColor("#a9e2a0");
            case 9:
                return Color.parseColor("#70cec7");
            default:
                return Color.GRAY;
        }
    }
    
    private static final int ENABLE_ATTR = android.R.attr.state_enabled;
	private static final int CHECKED_ATTR = android.R.attr.state_checked;
	private static final int PRESSED_ATTR = android.R.attr.state_pressed;

	public static ColorStateList generateThumbColorWithTintColor(final int tintColor) {
		int[][] states = new int[][]{
				{-ENABLE_ATTR, CHECKED_ATTR},
				{-ENABLE_ATTR},
				{PRESSED_ATTR, -CHECKED_ATTR},
				{PRESSED_ATTR, CHECKED_ATTR},
				{CHECKED_ATTR},
				{-CHECKED_ATTR}
		};

		int[] colors = new int[] {
				tintColor - 0xAA000000,
				0xFFBABABA,
				tintColor - 0x99000000,
				tintColor - 0x99000000,
				tintColor | 0xFF000000,
				0xFFEEEEEE
		};
		return new ColorStateList(states, colors);
	}

	public static ColorStateList generateBackColorWithTintColor(final int tintColor) {
		int[][] states = new int[][]{
				{-ENABLE_ATTR, CHECKED_ATTR},
				{-ENABLE_ATTR},
				{CHECKED_ATTR, PRESSED_ATTR},
				{-CHECKED_ATTR, PRESSED_ATTR},
				{CHECKED_ATTR},
				{-CHECKED_ATTR}
		};

		int[] colors = new int[] {
				tintColor - 0xE1000000,
				0x10000000,
				tintColor - 0xD0000000,
				0x20000000,
				tintColor - 0xD0000000,
				0x20000000
		};
		return new ColorStateList(states, colors);
	}
}
